class Solution {
public:
    int longestPalindrome(string s)
    {
        int c[128] = {0};
        int flag = 0;
        int len = 0;
        for(int i = 0;i < s.size();++i) {
            c[s[i]]++;
        }
        for(int i = 0;i < 128;++i) {
            if(c[i] % 2) {
                flag = 1;
            }
            len += c[i] / 2 * 2;
        }
        return len + flag;
    }
};